<?php
include_once ("mysqllib.php");
include_once ("video.php");
include_once ("slide.php");
include_once ("annotation.php");

class uploadVideo {
	public function displayUploadForm() {
		$this -> uploadForm();
	}

	public function uploadForm() {
		echo '<form method="POST" action="uploadAndConvertVideo.php" enctype="multipart/form-data">';
		echo '<label for="videoUpload">Video Files :</label><br/>';
		echo ' <input type="file" name="videoUpload1" id="videoUpload1" required="required"/><br/>';
		echo ' <input type="file" name="videoUpload2" id="videoUpload2" required="required"/><br/>';
		echo '<label for="idCourse">Course : </label><br/>';
		echo '<input type="number" name="idCourse" id="idCourse" required="required"/><br/>';
		echo '<label for="slidesUpload">Slides (pdf only) :</label><br/>';
		echo '<input type="file" name="slidesUpload" id="slidesUpload"/><br/>';
		echo '<label for="slidesUploadFile">Slides configuration : (optional)</label><br/>';
		echo '<input type="file" name="slidesUploadFile" id="slidesUploadFile"/><br/>';
		echo '<input type="submit" value="Start Uploading"/>';
		echo '</form>';
	}

	public function errorHandling($errV, $errS) {
		//check if an errors occured on the previous upload
		echo '<div id="uploadErrorReport">';
		//error on the video upload
		if (isset($errV)) {
			switch($errV) {
				case '-5' :
					echo "The folder for this video already exists. Please change the name of the video and try again.<br/>";
					break;
				case '-4' :
					echo "Could not create the folder. Please try again.<br/>";
					break;
				case '-3' :
					echo "Error during the conversion of the video. Please try again.<br/>";
					break;
				case '-2' :
					echo "Error in the database during the upload. Please try again.<br/>";
					break;
				case '-1' :
					echo "Error during the upload, the file is not in the right place on the server. Please try again.<br/>";
					break;
				case '4' :
					//UPLOAD_ERR_NO_FILE
					echo "The specified file does not exist. Please try again.<br/>";
					break;
				case '1' :
					//UPLOAD_ERR_INI_SIZE
					echo "The video is too heavy (>2Go). Try again with a lighter one.<br/>";
					break;
				case '2' :
					//UPLOAD_ERR_FORM_SIZE
					echo "The video is too heavy (>2Go). Try again with a lighter one.<br/>";
					break;
				case '3' :
					//UPLOAD_ERR_PARTIAL
					echo "The video was partially transfered. Please try again.<br/>";
					break;
			}
		}

		//error on the slides
		if (isset($errS)) {
			switch($_GET['errS']) {
				case '-1' :
					echo "Error during the upload, the file is not in the right place. Please try again.<br/>";
					break;
				case '-2' : 
					echo "Could not create folder. Please try again.<br/>";
					break;
				case '-3' : 
					echo "The configuration file is not valid. Please check it and try again.<br/>";
					break;
				case '4' :
					//UPLOAD_ERR_NO_FILE
					echo "The specified file does not exist. Please try again.<br/>";
					break;
				case '1' :
					//UPLOAD_ERR_INI_SIZE
					echo "The pdf is too heavy (>2Go). Try again with a lighter one.<br/>";
					break;
				case '2' :
					//UPLOAD_ERR_FORM_SIZE
					echo "The pdf is too heavy (>2Go). Try again with a lighter one.<br/>";
					break;
				case '3' :
					//UPLOAD_ERR_PARTIAL
					echo "The pdf was partially transfered. Please try again.<br/>";
					break;
			}
		}
		echo '</div>';
	}

}
?>